var a = [3, 'a', 'a', 'a', 2, 3, 'a', 3, 'a', 2, 4, 9, 3];
function findMost(arr) {
    if (!arr.length) return
    if (arr.length === 1) return 1
    let res = {}
    let maxName, maxNum = 0
    // 遍历数组
    arr.forEach((item) => {
        res[item] ? res[item] += 1 : res[item] = 1
    })
    // 遍历 res
    for (let r in res) {
        if (res[r] > maxNum) {
            maxNum = res[r]
            maxName = r
        }
    }
    return '出现次数最多的元素为:' + maxName + ', 出现次数为:' + maxNum;
}
document.write(findMost(a))